package com.company.creature;

import com.company.inter.Sets;


import java.util.ArrayList;

/**
 * @description:
 * @author: ZhaoYicong
 * @date: Created in 2020/4/26 13:16
 * @version: v1.0
 * @modified By:
 */
public class MonsterSet implements Sets {

    ArrayList<Monster> monsters=new ArrayList<>();
    @Override
    public Monster searchById(String id){
        Monster monster =null;
        for (Monster item:monsters){
            if (item.getId().equals(id)){
                monster=item;
            }
        }
        return monster;
    }
    public Monster searchByIdandfloor (String id,Creature creature ){
        Monster monster =null;
        for (Monster item:monsters){
            if (item.getNowRoom()==creature.getNowRoom()&&item.getId().equals(id)  ){
                monster=item;
                break;
            }
        }
        return monster;
    }

    @Override
    public void add(Object object) {
        if (object instanceof Monster){
            monsters.add((Monster) object);
        }
        else{
            System.out.println("类型不对");
        }

    }


    public ArrayList<Monster> getMonsters() {
        return monsters;
    }

    public void setMonsters(ArrayList<Monster> monsters) {
        this.monsters = monsters;
    }

    public MonsterSet(ArrayList<Monster> monsters) {
        this.monsters = monsters;
    }

    public MonsterSet() {
    }

//    @Override
//    public Object searchByID(String id) {
//        return null;
//    }
}
